package com.css.crm.vo;

import java.util.Date;
import java.util.List;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import org.apache.solr.client.solrj.beans.Field;

import com.css.crm.utility.DateUtil;

/**
 * Customer record
 */
@XmlRootElement(name = "customer")
public class CustomerVo extends AuditTrailVo {

	public CustomerVo() {
	}

	@Field
	private String custId;
	private String title;
	private String sex;
	@Field
	private String namEng;
	@Field
	private String namZht;
	@Field
	private String namZhs;
	private Date dob;
	private Long origCtryCde;
	private String remark1;
	private String remark2;
	private String mbrClass;
	private String frChanl;
	private String acctNam;
	private String pwd;
	private String prefLang;
	private String statCde;
	private String crtDeptCde;
	private Date crtDte;
	private String joinDeptCde;
	private Date joinDte;
	private Date actvDte;
	private Date lastModDte;
	private String lastModUser;
	private CustomerActivityVo customerActivity;
	private List<CustomerAddressVo> customerAddressList;
	private List<CustomerAttributeVo> customerAttributeList;
	private List<CustomerDiscountVo> customerDiscountList;
	private List<CustomerEmailVo> customerEmailList;
	private List<CustomerServiceEventVo> customerServiceEventList;
	private List<CustomerTelephoneVo> customerTelephoneList;
	private List<CustomerAddressVo> customerAddressListDeleted;
	private List<CustomerAttributeVo> customerAttributeListDeleted;
	private List<CustomerDiscountVo> customerDiscountListDeleted;
	private List<CustomerEmailVo> customerEmailListDeleted;
	private List<CustomerServiceEventVo> customerServiceEventListDeleted;
	private List<CustomerTelephoneVo> customerTelephoneListDeleted;
	private String dobMonth;
	private String dobDay;
	@Field
	private String gender;
	@Field
	private String birthday;
	@Field
	private String emailTypeCode;
	@Field
	private String email;
	@Field
	private String telePhoneTypeCode;
	@Field
	private String telNbr;

	public String getGender() {
		return gender;
	}

	public void setGender(String gender) {
		this.gender = gender;
	}

	public String getBirthday() {
		return birthday;
	}

	public void setBirthday(String birthday) {
		this.birthday = birthday;
	}

	public String getEmailTypeCode() {
		return emailTypeCode;
	}

	public void setEmailTypeCode(String emailTypeCode) {
		this.emailTypeCode = emailTypeCode;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getTelePhoneTypeCode() {
		return telePhoneTypeCode;
	}

	public void setTelePhoneTypeCode(String telePhoneTypeCode) {
		this.telePhoneTypeCode = telePhoneTypeCode;
	}

	public String getTelNbr() {
		return telNbr;
	}

	public void setTelNbr(String telNbr) {
		this.telNbr = telNbr;
	}

	public String getDobMonth() {
		return dobMonth;
	}

	public void setDobMonth(String dobMonth) {
		this.dobMonth = dobMonth;
	}

	public String getDobDay() {
		return dobDay;
	}

	public void setDobDay(String dobDay) {
		this.dobDay = dobDay;
	}

	@XmlElement
	public String getCustId() {
		return custId;
	}

	public void setCustId(String custId) {
		this.custId = custId;
	}

	@XmlElement
	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	@XmlElement
	public String getNamEng() {
		return namEng;
	}

	public void setNamEng(String namEng) {
		this.namEng = namEng;
	}

	@XmlElement
	public String getNamZht() {
		return namZht;
	}

	public void setNamZht(String namZht) {
		this.namZht = namZht;
	}

	@XmlElement
	public String getNamZhs() {
		return namZhs;
	}

	public void setNamZhs(String namZhs) {
		this.namZhs = namZhs;
	}

	@XmlElement
	public Date getDob() {
		return dob;
	}

	public void setDob(Date dob) {
		this.dob = dob;
	}

	@XmlElement
	public Long getOrigCtryCde() {
		return origCtryCde;
	}

	public void setOrigCtryCde(Long origCtryCde) {
		this.origCtryCde = origCtryCde;
	}

	@XmlElement
	public String getRemark1() {
		return remark1;
	}

	public void setRemark1(String remark1) {
		this.remark1 = remark1;
	}

	@XmlElement
	public String getRemark2() {
		return remark2;
	}

	public void setRemark2(String remark2) {
		this.remark2 = remark2;
	}

	@XmlElement
	public String getMbrClass() {
		return mbrClass;
	}

	public void setMbrClass(String mbrClass) {
		this.mbrClass = mbrClass;
	}

	@XmlElement
	public String getFrChanl() {
		return frChanl;
	}

	public void setFrChanl(String frChanl) {
		this.frChanl = frChanl;
	}

	@XmlElement
	public String getAcctNam() {
		return acctNam;
	}

	public void setAcctNam(String acctNam) {
		this.acctNam = acctNam;
	}

	@XmlElement
	public String getPwd() {
		return pwd;
	}

	public void setPwd(String pwd) {
		this.pwd = pwd;
	}

	@XmlElement
	public String getPrefLang() {
		return prefLang;
	}

	public void setPrefLang(String prefLang) {
		this.prefLang = prefLang;
	}

	@XmlElement
	public String getStatCde() {
		return statCde;
	}

	public void setStatCde(String statCde) {
		this.statCde = statCde;
	}

	@XmlElement
	public String getCrtDeptCde() {
		return crtDeptCde;
	}

	public void setCrtDeptCde(String crtDeptCde) {
		this.crtDeptCde = crtDeptCde;
	}

	@XmlElement
	public Date getCrtDte() {
		return crtDte;
	}

	public void setCrtDte(Date crtDte) {
		this.crtDte = crtDte;
	}

	@XmlElement
	public String getJoinDeptCde() {
		return joinDeptCde;
	}

	public void setJoinDeptCde(String joinDeptCde) {
		this.joinDeptCde = joinDeptCde;
	}

	@XmlElement
	public Date getJoinDte() {
		return joinDte;
	}

	public void setJoinDte(Date joinDte) {
		this.joinDte = joinDte;
	}

	@XmlElement
	public Date getActvDte() {
		return actvDte;
	}

	public void setActvDte(Date actvDte) {
		this.actvDte = actvDte;
	}

	@XmlElement
	public Date getLastModDte() {
		return lastModDte;
	}

	public void setLastModDte(Date lastModDte) {
		this.lastModDte = lastModDte;
	}

	@XmlElement
	public String getLastModUser() {
		return lastModUser;
	}

	public void setLastModUser(String lastModUser) {
		this.lastModUser = lastModUser;
	}

	@XmlElement
	public CustomerActivityVo getCustomerActivity() {
		return customerActivity;
	}

	public void setCustomerActivity(CustomerActivityVo customerActivity) {
		this.customerActivity = customerActivity;
	}

	@XmlElement
	public List<CustomerAddressVo> getCustomerAddressList() {
		return customerAddressList;
	}

	public void setCustomerAddressList(List<CustomerAddressVo> customerAddressList) {
		this.customerAddressList = customerAddressList;
	}

	@XmlElement
	public List<CustomerAttributeVo> getCustomerAttributeList() {
		return customerAttributeList;
	}

	public void setCustomerAttributeList(List<CustomerAttributeVo> customerAttributeList) {
		this.customerAttributeList = customerAttributeList;
	}

	@XmlElement
	public List<CustomerDiscountVo> getCustomerDiscountList() {
		return customerDiscountList;
	}

	public void setCustomerDiscountList(List<CustomerDiscountVo> customerDiscountList) {
		this.customerDiscountList = customerDiscountList;
	}

	@XmlElement
	public List<CustomerEmailVo> getCustomerEmailList() {
		return customerEmailList;
	}

	public void setCustomerEmailList(List<CustomerEmailVo> customerEmailList) {
		this.customerEmailList = customerEmailList;
	}

	@XmlElement
	public List<CustomerServiceEventVo> getCustomerServiceEventList() {
		return customerServiceEventList;
	}

	public void setCustomerServiceEventList(List<CustomerServiceEventVo> customerServiceEventList) {
		this.customerServiceEventList = customerServiceEventList;
	}

	@XmlElement
	public List<CustomerTelephoneVo> getCustomerTelephoneList() {
		return customerTelephoneList;
	}

	public void setCustomerTelephoneList(List<CustomerTelephoneVo> customerTelephoneList) {
		this.customerTelephoneList = customerTelephoneList;
	}

	public List<CustomerAddressVo> getCustomerAddressListDeleted() {
		return customerAddressListDeleted;
	}

	public void setCustomerAddressListDeleted(List<CustomerAddressVo> customerAddressListDeleted) {
		this.customerAddressListDeleted = customerAddressListDeleted;
	}

	public List<CustomerAttributeVo> getCustomerAttributeListDeleted() {
		return customerAttributeListDeleted;
	}

	public void setCustomerAttributeListDeleted(List<CustomerAttributeVo> customerAttributeListDeleted) {
		this.customerAttributeListDeleted = customerAttributeListDeleted;
	}

	public List<CustomerDiscountVo> getCustomerDiscountListDeleted() {
		return customerDiscountListDeleted;
	}

	public void setCustomerDiscountListDeleted(List<CustomerDiscountVo> customerDiscountListDeleted) {
		this.customerDiscountListDeleted = customerDiscountListDeleted;
	}

	public List<CustomerEmailVo> getCustomerEmailListDeleted() {
		return customerEmailListDeleted;
	}

	public void setCustomerEmailListDeleted(List<CustomerEmailVo> customerEmailListDeleted) {
		this.customerEmailListDeleted = customerEmailListDeleted;
	}

	public List<CustomerServiceEventVo> getCustomerServiceEventListDeleted() {
		return customerServiceEventListDeleted;
	}

	public void setCustomerServiceEventListDeleted(List<CustomerServiceEventVo> customerServiceEventListDeleted) {
		this.customerServiceEventListDeleted = customerServiceEventListDeleted;
	}

	public List<CustomerTelephoneVo> getCustomerTelephoneListDeleted() {
		return customerTelephoneListDeleted;
	}

	public void setCustomerTelephoneListDeleted(List<CustomerTelephoneVo> customerTelephoneListDeleted) {
		this.customerTelephoneListDeleted = customerTelephoneListDeleted;
	}

	@XmlElement
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	@Override
	public int compareTo(AuditTrailVo o) {
		CustomerVo vo = (CustomerVo) o;
		int result = 0;
		if (vo == null) {
			// if not set original data, default set to modified.
			return 1;
		}
		String title = this.getTitle() == null ? "" : this.getTitle();
		String sex = this.getSex() == null ? "" : this.getSex();
		String frChanel = this.getFrChanl() == null ? "" : this.getFrChanl();
		String engName = this.getNamEng() == null ? "" : this.getNamEng();
		String zhtName = this.getNamZht() == null ? "" : this.getNamZht();
		String zhsName = this.getNamZhs() == null ? "" : this.getNamZhs();
		String birthday = DateUtil.formatDate(this.getDob());
		birthday = birthday == null ? "" : birthday;
		String remark1 = this.getRemark1() == null ? "" : this.getRemark1();
		String remark2 = this.getRemark2() == null ? "" : this.getRemark2();
		String titleCompareTo = vo.getTitle() == null ? "" : vo.getTitle();
		String sexCompareTo = vo.getSex() == null ? "" : vo.getSex();
		String frChanelCompareTo = vo.getFrChanl() == null ? "" : vo.getFrChanl();
		String engNameCompareTo = vo.getNamEng() == null ? "" : vo.getNamEng();
		String zhtNameCompareTo = vo.getNamZht() == null ? "" : vo.getNamZht();
		String zhsNameCompareTo = vo.getNamZhs() == null ? "" : vo.getNamZhs();
		String birthdayCompareTo = DateUtil.formatDate(vo.getDob());
		String statCdeTo = vo.getStatCde()==null ? "" : vo.getStatCde();
		birthdayCompareTo = birthdayCompareTo == null ? "" : birthdayCompareTo;
		String remark1CompareTo = vo.getRemark1() == null ? "" : vo.getRemark1();
		String remark2CompareTo = vo.getRemark2() == null ? "" : vo.getRemark2();
		// check if have any field be modified
		if (!title.equals(titleCompareTo)) {
			result = 1;
		}
		if (!sex.equals(sexCompareTo)) {
			result = 1;
		}
		if (!frChanel.equals(frChanelCompareTo)) {
			result = 1;
		}
		if (!engName.equals(engNameCompareTo)) {
			result = 1;
		}
		if (!zhtName.equals(zhtNameCompareTo)) {
			result = 1;
		}
		if (!zhsName.equals(zhsNameCompareTo)) {
			result = 1;
		}
		if (!birthday.equals(birthdayCompareTo)) {
			result = 1;
		}
		if(!statCde.equals(statCdeTo)) {
			result = 1;
		}
		if (!remark1.equals(remark1CompareTo)) {
			result = 1;
		}
		if (!remark2.equals(remark2CompareTo)) {
			result = 1;
		}
		return result;
	}
}
